package com.medical.server.sickroom.controller;

import java.util.Arrays;
import java.util.Map;

import com.laozj.common.utils.PageUtils;
import com.laozj.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.medical.server.sickroom.entity.SickBedEntity;
import com.medical.server.sickroom.service.SickBedService;



/**
 * 
 *
 * @author laozj
 * @email laozj@medical.com
 * @date 2024-09-01 15:19:30
 */
@Api(tags = "病床接口")
@RestController
@RequestMapping("sickroom/sickbed")
public class SickBedController {

    @Autowired
    private SickBedService sickBedService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation("查询病床列表接口")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sickBedService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bedId}")
    @ApiOperation("根据id查询病床接口")
    public R info(@PathVariable("bedId") Long bedId){
		SickBedEntity sickBed = sickBedService.getById(bedId);

        return R.ok().put("sickBed", sickBed);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation("保存病床接口")
    public R save(@RequestBody SickBedEntity sickBed){
		sickBedService.save(sickBed);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation("修改病床接口")
    public R update(@RequestBody SickBedEntity sickBed){
		sickBedService.updateById(sickBed);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ApiOperation("删除病床接口")
    public R delete(@RequestBody Long[] bedIds){
		sickBedService.removeByIds(Arrays.asList(bedIds));

        return R.ok();
    }

}
